home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / EXAMP3.SQL < prev    next >
Encoding:
Text File  |  1995-05-18  |  1.1 KB  |  40 lines

  1. rem 
  2. rem $Header: examp3.sql 7020100.1 94/09/28 16:39:53 cli Generic<base> $ 
  3. rem 
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      examp3.sql - <one-line expansion of the name>
  7. Rem    DESCRIPTION
  8. Rem      <short description of component this file declares/defines>
  9. Rem    RETURNS
  10. Rem 
  11. Rem    NOTES
  12. Rem      <other useful comments, qualifications, etc.>
  13. Rem    MODIFIED   (MM/DD/YY)
  14. Rem     rvasired   05/12/92 -  Creation 
  15. /*
  16. ** This block finds the first employee who has a salary over $4000
  17. ** and is higher in the chain of command than employee 7902.
  18. **
  19. ** Copyright (c) 1989,1992 Oracle Corporation
  20. */
  21.  
  22. DECLARE
  23.     salary          emp.sal%TYPE;
  24.     mgr_num         emp.mgr%TYPE;
  25.     last_name       emp.ename%TYPE;
  26.     starting_empno  CONSTANT NUMBER(4) := 7902;
  27. BEGIN
  28.     SELECT sal, mgr INTO salary, mgr_num FROM emp
  29.         WHERE empno = starting_empno;
  30.     WHILE salary < 4000 LOOP
  31.         SELECT sal, mgr, ename INTO salary, mgr_num, last_name
  32.             FROM emp
  33.             WHERE empno = mgr_num;
  34.     END LOOP;
  35.  
  36.     INSERT INTO temp VALUES (NULL, salary, last_name);
  37.     COMMIT;
  38. END;
  39. /
  40.